package com.example.springalibabacloudclient.controller;

import com.alibaba.fastjson.JSONObject;
import com.example.springalibabacloudclient.feign.ProviderFeign;
import com.example.springalibabacloudclient.feign.TestFeign;
import com.example.springalibabacloudclient.utils.Results;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Primary;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import java.util.HashMap;

/**
 * @Classname FeignController
 * @Description TODO
 * @Date 2022/5/14 11:33
 * @Created by XiongXiong
 * @Author: X.I.O
 */
@RestController
@Slf4j
@RequestMapping("feign")
public class FeignController {

    @Autowired
    private TestFeign testFeign;

    @Autowired
    private ProviderFeign providerFeign;

    @GetMapping("v1")
    public JSONObject v1Controller(){
        log.info("走到v1==================>");
        return Results.success();
    }

    @GetMapping("v2")
    public String v3Controller(){
        return testFeign.getJSONObject();
    }

    /**
     * 127.0.0.1:8012/feign/v4
     *
     * @return
     */
    @GetMapping("v4")
    public JSONObject v4Controller(){
        return providerFeign.proV3();
    }
}
